package com.foreveredu.erlms.persist.hibernate;

import java.util.List;

import com.foreveredu.erlms.domain.Rank;
import com.foreveredu.erlms.persist.IRankDao;

public class HibernateRankDao extends HibernateAbstractDao<Rank, Integer> implements IRankDao {

	private static final long serialVersionUID = 1L;

	public HibernateRankDao() {
		super(Rank.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Rank> findRanksOfEnabled() {
		return this.getHibernateTemplate().find("from Rank r where r.flag = 1");
	}

	@SuppressWarnings("unchecked")
	@Override
	public Rank findRankByCode(String code) {
		List<Rank> rankList = this.getHibernateTemplate().find("from Rank r where r.code = ?", code);
		Rank rank = null;
		if (rankList != null && rankList.size() > 0) {
			rank = rankList.get(0);
		}
		return rank;
	}

}
